{set:
	$site_config=new Config('site_config');
	$seo_data=array();
	$seo_data['title']=$site_config->name;
	$seo_data['title'].=$site_config->index_seo_title;
	$seo_data['keywords']=$site_config->index_seo_keywords;
	$seo_data['description']=$site_config->index_seo_description;
	seo::set($seo_data);
}

<link rel="stylesheet" type="text/css" href="{theme:javascript/jquery.bxSlider/jquery.bxslider.css}" />
<script type="text/javascript" src="{theme:javascript/jquery.bxSlider/jquery.bxSlider.min.js}"></script>

<div class="wrapper clearfix">
	<div class="sidebar f_r">

		<!--cms新闻展示-->
		<div class="box m_10">
			<div class="title"><h2>Shop资讯</h2><a class="more" href="{url:/site/article}">更多...</a></div>
			<div class="cont">
				<ul class="list">
					{query:name=article where=visiblity eq 1 and top eq 1 order=sort ASC,id DESC fields=title,id,style,color limit=5}
					{set:$tmpId=$item['id'];}
					<li><a href="{url:/site/article_detail/id/$tmpId}">{echo:Article::showTitle($item['title'],$item['color'],$item['style'])}</a></li>
					{/query}
				</ul>
			</div>
		</div>
		<!--cms新闻展示-->

		<div class="box">
			<div id="adHere_7"></div>
			<script language="javascript">
			(new adLoader()).load(7,'adHere_7');
			</script>
		</div>
	</div>

	<!--幻灯片 开始-->
	<div class="main f_l">
		{if:$this->index_slide}
		<ul class="bxslider">
			{foreach:items=$this->index_slide}
			<li title="{$item['name']}"><a href="{url:$item[url]}" target="_blank"><img src="{webroot:$item[img]}" width="750px" title="{$item['name']}" /></a></li>
			{/foreach}
		</ul>
		{/if}
	</div>
	<!--幻灯片 结束-->
</div>

<div class="m_10">
	<div id="adHere_6"></div>
	<script language="javascript">
	(new adLoader()).load(6,'adHere_6');
	</script>
</div>

<div class="wrapper clearfix">
	<div class="sidebar f_r">

		<!--团购-->
		<div class="group_on box m_10">
			<div class="title"><h2>团购商品</h2><a class="more" href="{url:/site/groupon}">更多...</a></div>
			<div class="cont">
				<ul class="ranklist">
					{query:name=regiment where=is_close eq 0 and NOW() between start_time and end_time limit=5 fields=id,title,regiment_price,img order=id desc}
					<li class="current">
						{set:$tmpId=$item['id'];}
						<a href="{url:/site/groupon/id/$tmpId}"><img width="60px" height="60px" alt="{$item['title']}" src="{webroot:$item[img]}"></a>
						<a class="p_name" title="{$item['title']}" href="{url:/site/groupon/id/$tmpId}">{$item['title']}</a><p class="light_gray">团购价：<em>￥{$item['regiment_price']}</em></p>
					</li>
					{/query}
				</ul>
			</div>
		</div>
		<!--团购-->

		<!--限时抢购-->
		<div class="buying box m_10">
			<div class="title"><h2>限时抢购</h2></div>
			<div class="cont clearfix">
				<ul class="prolist">
					{set:$countNumsItem = array();}
					{query:name=promotion as p join=left join goods as go on go.id eq p.condition fields=p.end_time,go.list_img as list_img,p.name as name,p.award_value as award_value,go.id as goods_id,p.id as p_id,end_time where=p.type eq 1 and p.is_close eq 0 and go.is_del eq 0 and NOW() between start_time and end_time AND go.id is not null limit=2}
					{set:$free_time = ITime::getDiffSec($item['end_time'])}
					{set:$countNumsItem[] = $item['p_id'];}
					<li>
						<p class="countdown">倒计时:<br /><b id='cd_hour_{$item['p_id']}'>{echo:floor($free_time/3600);}</b>时<b id='cd_minute_{$item['p_id']}'>{echo:floor(($free_time%3600)/60);}</b>分<b id='cd_second_{$item['p_id']}'>{echo:$free_time%60;}</b>秒</p>
						{set:$tmpGoodsId=$item['goods_id'];$tmpPId=$item['p_id'];}
						<a href="{url:/site/products/id/$tmpGoodsId/promo/time/active_id/$tmpPId}"><img src="{webroot:$item[list_img]}" width="175" height="175" alt="{$item['name']}" title="{$item['name']}" /></a>
						<p class="pro_title"><a href="{url:/site/products/id/$tmpGoodsId/promo/time/active_id/$tmpPId}">{$item['name']}</a></p>
						<p class="light_gray">抢购价：<b>￥{$item['award_value']}</b></p>
						<div></div>
					</li>
					{/query}
				</ul>
			</div>
		</div>
		<!--限时抢购-->

		<!--热卖商品-->
		<div class="hot box m_10">
			<div class="title"><h2>热卖商品</h2></div>
			<div class="cont clearfix">
				<ul class="prolist">
					{query:name=commend_goods as co join=left join goods as go on co.goods_id eq go.id where=co.commend_id eq 3 and go.is_del eq 0 AND go.id is not null fields=go.list_img,go.sell_price,go.name,go.id limit=8 order=sort asc,id desc}
					{set:$tmpId=$item['id']}
					<li>
						<a href="{url:/site/products/id/$tmpId}"><img src="{webroot:$item[list_img]}" width="85" height="85" alt="{$item['name']}" /></a>
						<p class="pro_title"><a href="{url:/site/products/id/$tmpId}">{$item['name']}</a></p>
						<p class="brown"><b>￥{$item['sell_price']}</b></p>
					</li>
					{/query}
				</ul>
			</div>
		</div>
		<!--热卖商品-->

		<!--公告通知-->
		<div class="box m_10">
			<div class="title"><h2>公告通知</h2><a class="more" href="{url:/site/notice}">更多...</a></div>
			<div class="cont">
				<ul class="list">
					{query:name=announcement limit=5 order=id desc}
					{set:$tmpId=$item['id'];}
					<li><a href="{url:/site/notice_detail/id/$tmpId}">{$item['title']}</a></li>
					{/query}
				</ul>
			</div>
		</div>
		<!--公告通知-->

		<!--关键词-->
		<div class="box m_10">
			<div class="title"><h2>关键词</h2><a class="more" href="{url:/site/tags}">更多...</a></div>
			<div class="tag cont t_l">
				{query:name=keyword where=hot eq 1 limit=8 order=`order` asc}
				{set:$searchWord =urlencode($item['word']);}
				<a href="{url:/site/search_list/word/$searchWord}" class="orange">{$item['word']}</a>
				{/query}
			</div>
		</div>
		<!--关键词-->

		<!--电子订阅-->
		<div class="book box m_10">
			<div class="title"><h2>电子订阅</h2></div>
			<div class="cont">
				<p>我们会将最新的资讯发到您的Email</p>
				<input type="text" class="gray_m light_gray f_l" name='orderinfo' value="输入您的电子邮箱地址" />
				<label class="btn_orange"><input type="button" onclick="orderinfo();" value="订阅" /></label>
			</div>
		</div>
		<!--电子订阅-->
	</div>

	<div class="main f_l">
		<!--商品分类展示-->
		<div class="category box">
			<div class="title2">
				<h2><img src="{skin:images/front/category.gif}" alt="商品分类" width="155" height="36" /></h2>
				<a class="more" href="{url:/site/sitemap}">全部商品分类</a>
			</div>
		</div>

		<table id="index_category" class="sort_table m_10" width="100%">
			<col width="100px" />
			<col />
			{foreach:items=$this->goodsCategory item=$first}
			{if:$first['visibility'] == 1}
			{set:$tmpFirstId=$first['id'];}
			<tr>
				<th><a href="{url:/site/pro_list/cat/$tmpFirstId}">{$first['name']}</a></th>
				<td>
					{if:isset($first['second'])}
					{foreach:items=$first['second'] item=$second}
						{if:$second['visibility'] == 1}
						{set:$tmpSecondId=$second['id'];}
						<a href="{url:/site/pro_list/cat/$tmpSecondId}">{$second['name']}</a> |
						{/if}
					{/foreach}
					{/if}
				</td>
			</tr>
			{/if}
			{/foreach}
		</table>
		<!--商品分类展示-->

		<!--最新商品-->
		<div class="box yellow m_10">
			<div class="title2">
				<h2><img src="{skin:images/front/new_product.gif}" alt="最新商品" width="160" height="36" /></h2>
			</div>
			<div class="cont clearfix">
				<ul class="prolist">
					{query:name=commend_goods as co join=left join goods as go on co.goods_id eq go.id where=co.commend_id eq 1 and go.is_del eq 0 AND go.id is not null fields=go.list_img,go.sell_price,go.name,go.market_price,go.id limit=8 order=id desc group = id}
					{set:$tmpId=$item['id'];}
					<li style="overflow:hidden">
						<a href="{url:/site/products/id/$tmpId}"><img src="{webroot:$item[list_img]}" width="175" height="175" alt="{$item['name']}" /></a>
						<p class="pro_title"><a title="{$item['name']}" href="{url:/site/products/id/$tmpId}">{$item['name']}</a></p>
						<p class="brown">惊喜价：<b>￥{$item['sell_price']}</b></p>
						<p class="light_gray">市场价：<s>￥{$item['market_price']}</s></p>
					</li>
					{/query}
				</ul>
			</div>
		</div>
		<!--最新商品-->

		<!--首页推荐商品-->
		{foreach:items=$this->goodsCategory item=$first}
		{if:$first['visibility'] == 1}
		{set:$tmpFirstId=$first['id'];}
		<div class="box m_10" name="showGoods">
			<div class="title title3">
				<h2><a href="{url:/site/pro_list/cat/$tmpFirstId}"><strong>{$first['name']}</strong></a></h2>
				<a class="more" href="{url:/site/pro_list/cat/$tmpFirstId}">更多商品...</a>
				<ul class="category">
					{set:$secondIdArray = array()}
					{if:isset($first['second'])}
					{foreach:items=$first['second'] item=$second}
						{if:$second['visibility'] == 1}
							{set:$secondIdArray[] = $second['id']}
							{if:$second['more']}
								{foreach:items=$second['more'] item=$v}
									{set:$secondIdArray[] = $v['id']}
								{/foreach}
							{/if}
							{set:$tmpSecondId=$second['id'];}
							<li><a href="{url:/site/pro_list/cat/$tmpSecondId}">{$second['name']}</a><span></span></li>
						{/if}
					{/foreach}
					{/if}
				</ul>
			</div>

			<div class="cont clearfix">
				<ul class="prolist">
					{set:$recomCatId = $first['id']}
					{if:!empty($secondIdArray)}
						{set:$recomCatId .= ','.join(',', $secondIdArray );}
					{/if}
					{query:name=category_extend as ca join = left join goods as go on go.id eq ca.goods_id where = ca.category_id in ($recomCatId) and go.is_del eq 0 limit = 8 order = go.sort asc,go.id desc fields= DISTINCT go.list_img,go.id,go.name,go.sell_price,go.market_price}
					<li style="overflow:hidden">
						{set:$tmpId=$item['id'];}
						<a href="{url:/site/products/id/$tmpId}"><img src="{webroot:$item[list_img]}" width="175" height="175" alt="{$item['name']}" title="{$item['name']}" /></a>
						<p class="pro_title"><a title="{$item['name']}" href="{url:/site/products/id/$tmpId}">{$item['name']}</a></p>
						<p class="brown">惊喜价：<b>￥{$item['sell_price']}</b></p>
						<p class="light_gray">市场价：<s>￥{$item['market_price']}</s></p>
					</li>
					{/query}
				</ul>
			</div>
		</div>
		{/if}
		{/foreach}

		<!--品牌列表-->
		<div class="brand box m_10">
			<div class="title2"><h2><img src="{skin:images/front/brand.gif}" alt="品牌列表" width="155" height="36" /></h2><a class="more" href="{url:/site/brand}">&lt;<span>全部品牌</span>&gt;</a></div>
			<div class="cont clearfix">
				<ul>
					{query:name=brand fields=id,name,logo order=sort asc limit=6}
					{set:$tmpId=$item['id'];}
					<li><a href="{url:/site/brand_zone/id/$tmpId}"><img src="{webroot:$item[logo]}"  width="110" height="50"/>{$item['name']}</a></li>
					{/query}
				</ul>
			</div>
		</div>
		<!--品牌列表-->

		<!--最新评论-->
		<div class="comment box m_10">
			<div class="title2"><h2><img src="{skin:images/front/comment.gif}" alt="最新评论" width="155" height="36" /></h2></div>
			<div class="cont clearfix">
				{query:name=comment as co
					join=left join goods as go on co.goods_id eq go.id
					order=co.id desc
					limit=6
					where=co.status eq 1 AND go.is_del eq 0 AND go.id is not null
					fields=go.list_img as list_img,go.name as name,co.point,co.contents,co.goods_id
				}
				<dl class="no_bg">
					{set:$tmpGoodsId=$item['goods_id'];}
					<dt><a href="{url:/site/products/id/$tmpGoodsId}"><img src="{webroot:$item[list_img]}" width="65" height="65" /></a></dt>
					<dd><a href="{url:/site/products/id/$tmpGoodsId}">{$item['name']}</a></dd>
					<dd><span class="grade"><i style="width:{echo:$item['point']*14}px"></i></span></dd>
					<dd class="com_c">{$item['contents']}</dd>
				</dl>
				{/query}
			</div>
		</div>
		<!--最新评论-->
	</div>
</div>

<script type='text/javascript'>
//dom载入完毕执行
jQuery(function()
{
	//幻灯片开启
	$('.bxslider').bxSlider({'mode':'fade','captions':true,'pager':false,'auto':true});

	//index 分类展示
	$('#index_category tr').hover(
		function(){
			$(this).addClass('current');
		},
		function(){
			$(this).removeClass('current');
		}
	);

	//email订阅 事件绑定
	var tmpObj = $('input:text[name="orderinfo"]');
	var defaultText = tmpObj.val();
	tmpObj.bind({
		focus:function(){checkInput($(this),defaultText);},
		blur :function(){checkInput($(this),defaultText);}
	});

	//显示抢购倒计时
	var cd_timer = new countdown();
	{foreach:items = $countNumsItem}
		cd_timer.add({$item});
	{/foreach}

	//首页商品变色
	var colorArray = ['green','yellow','purple'];
	$('div[name="showGoods"]').each(function(i)
	{
		$(this).addClass(colorArray[i%colorArray.length]);
	});
});

//电子邮件订阅
function orderinfo()
{
	var email = $('[name="orderinfo"]').val();
	if(email == '')
	{
		alert('请填写正确的email地址');
	}
	else
	{
		$.getJSON('{url:/site/email_registry}',{email:email},function(content){
			if(content.isError == false)
			{
				alert('订阅成功');
				$('[name="orderinfo"]').val('');
			}
			else
				alert(content.message);
		});
	}
}
</script>